import Vue from 'vue'
import App from './App.vue'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// ElementUI.Dialog.props.closeOnClickModal.default = false; // 修改 el-dialog 默认点击遮照为不关闭
Vue.use(ElementUI);

import './assets/css/resetcss.css'
import './assets/css/resetting.css'

//引入阿里矢量图标
import './assets/al-icon/iconfont.css'

import VueRouter from 'vue-router'
Vue.use(VueRouter)

import router from './router/index'

router.beforeEach((to, from, next) => {
  let token = localStorage.getItem("token");
  if (!token && to.name !== "login") {
    next({ name: 'login' })
    // } else if (token && to.name === 'login') {
    //   next({ name: 'main' })
  } else {
    next()
  }

  //返回 false 以取消导航
  return false
})

import store from './store'

// //动态路由
store.commit('initRoute');

//引入工具类
import { fn } from './utils/fn.js'
Vue.prototype.$fn = fn;

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
